package com.example.app1.pojo;

import com.example.app1.enums.ResultEnum;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class RestResp<T> {
    int code;
    String msg;
    T data;

    public static <T> RestResp<T> success(T data) {
        return new RestResp<>(ResultEnum.SUCCESS.getCode(), ResultEnum.SUCCESS.getMsg(), data);
    }

    public static <T> RestResp<T> fail(int code, String msg) {
        return new RestResp<>(code, msg, null);
    }

    public static <T> RestResp<T> fail(int code, String msg, T data) {
        return new RestResp<>(code, msg, data);
    }
}
